package com.example.controller;

import com.example.common.Result;
import com.example.entity.PetHealth;
import com.example.service.PetHealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author HY
 * @date 2025/2/18
 */
@RestController
@RequestMapping("/petHealth")
public class PetHealthController {
    @Autowired
    private PetHealthService petHealthService;

    @GetMapping("/query/user")
    public Result selectByUserId() {
        PetHealth petHealth = petHealthService.selectByUserId();
        return Result.success(petHealth);
    }

    @PostMapping("/save")
    public Result save(@RequestBody PetHealth petHealth) {
        petHealthService.save(petHealth);
        return Result.success();
    }

    @GetMapping("/list")
    public Result list(Integer pageSize, Integer pageNum, PetHealth petHealth) {
        return Result.success(petHealthService.listPage(pageSize, pageNum, petHealth));
    }

    @GetMapping("/queryById/{id}")
    public Result queryById(@PathVariable Integer id) {
        PetHealth petHealth = petHealthService.queryById(id);
        return Result.success(petHealth);
    }

}
